#include "../ws2812/ws2812.h"
#include "count.h"

uint8_t n000[31][2]=
{
{0,2},{0,3},{0,4},{1,1},{1,5},{2,0},{2,6}
,{4,0},{5,0},{6,0},{7,0},{8,0},{9,0},{10,1}
,{11,2},{11,3},{11,4},{10,5},{9,6},{2,6}
,{3,6},{4,6},{5,6},{6,6},{7,6},{7,1},{6,2}
,{6,3},{5,4},{5,5},{4,5}

};

uint8_t n111[19][2]=
{
{2,1},{1,2},{0,3},{1,3},{2,3},{3,3},
{4,3},{5,3},{6,3},{7,3},{8,3},{9,3},
{10,3},{11,3},{11,1},{11,2},{11,4},{11,5},{11,6}
};

uint8_t n222[27][3]=
{
{2,0},{1,1},{0,2},{0,3},{0,4},{1,5},{2,6}
,{3,6},{4,6},{4,5},{5,5},{5,4},{6,4},{6,3}
,{7,3},{7,2},{8,2},{8,1},{9,1},{10,0},{11,0}
,{11,1},{11,2},{11,3},{11,4},{11,5},{11,6}
};

uint8_t n333[32][2]=
{
{2,0},{1,0},{1,1},{0,1},{0,2},{0,3},{0,4},{0,5}
,{1,5},{2,6},{3,6},{3,5},{4,5},{4,4},{5,2},{5,3}
,{5,4},{6,4},{6,5},{7,5},{7,6},{8,6},{9,0},{9,6}
,{10,0},{10,1},{10,5},{11,1},{11,2},{11,3},{11,4}
,{11,5}


};
// ,{,}
uint8_t n444[24][2]=
{
{0,2},{1,2},{2,2},{3,1},{4,1},{5,0},{6,0},{7,0}
,{8,0},{8,1},{8,2},{8,3},{8,4},{8,5},{8,6},{2,4}
,{3,4},{4,4},{5,4},{6,4},{7,4},{9,4},{10,4},{11,4}

};

uint8_t n555[23][2]=
{
 {0,1},{0,2},{0,3},{0,4},{0,5},{1,0},{2,0},{3,0}
,{4,0},{5,1},{5,2},{5,3},{5,4},{6,5},{7,6},{8,6}
,{9,6},{10,5},{10,0},{11,1},{11,2},{11,3},{11,4}

};

uint8_t n666[24][2]=
{
 {0,5},{0,4},{0,3},{1,2},{2,1},{3,1},{4,0},{5,0}
,{6,0},{7,0},{8,0},{9,0},{10,1},{11,2},{11,3},{11,4}
,{10,5},{9,6},{8,6},{7,6},{6,5},{6,4},{6,3},{6,2}

};

uint8_t n777[18][2]=
{
{0,0},{0,1},{0,2},{0,3},{0,4},{0,5},{0,6},{1,6}
,{2,6},{3,5},{4,5},{5,4},{6,4},{7,4},{8,3},{9,3}
,{10,3},{11,3}

};

uint8_t n888[33][2]=
{
{1,0},{2,0},{3,0},{4,0},{5,1},{5,2},{5,3},{5,4},{5,5},
{6,6},{7,6},{8,6},{9,6},{10,6},{11,5},{11,4},{11,3},{11,2},{11,1},
{10,0},{9,0},{8,0},{7,0},{6,0},
{4,6},{3,6},{2,6},{1,6},{0,5},{0,4},{0,3},{0,2},{0,1}

};

uint8_t n999[29][2]=
{
{1,0},{2,0},{3,0},{4,0},{5,1},{5,2},{5,3},{5,4},{5,5},
{6,6},{7,6},{8,6},{9,6},{10,6},{11,5},{11,4},{11,3},{11,2},{11,1},
{10,0},
{4,6},{3,6},{2,6},{1,6},{0,5},{0,4},{0,3},{0,2},{0,1}

};

uint8_t number[10]={31,19,27,32,24,23,24,18,33,29};



uint8_t show_row_column(uint8_t row,uint8_t column)
{
   if(row>15||column>15) return 0;
	 else if(row%2==0)
	 {
	     return ((row+1)*16-column-1);
	 }
   else if(row%2==1)
	 {
	     return ((row)*16+column);
	 }
   return 0;
}

uint8_t show_num(uint8_t num,uint8_t x,uint8_t y)
{
	switch (num)
{
        case 0:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n000[i][0]+x, n000[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;

      case 1:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n111[i][0]+x, n111[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;

      case 2:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n222[i][0]+x, n222[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;

      case 3:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n333[i][0]+x, n333[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;

      case 4:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n444[i][0]+x, n444[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;

      case 5:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n555[i][0]+x, n555[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;

      case 6:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n666[i][0]+x, n666[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;

      case 7:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n777[i][0]+x, n777[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;

      case 8:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n888[i][0]+x, n888[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;

      case 9:
        ws281x_closeAll();
        for (i = 0; i < number[num]; i++)
        {

          ws281x_setPixelRGB(show_row_column(n999[i][0]+x, n999[i][1]+y), 25, 0, 10);

          ws281x_show();
          HAL_Delay(4);
        }
        break;






	}
}

